<!--
 * @Author: zhangyonggui
 * @Date: 2023-12-14 15:58:32
 * @LastEditors: zhangyonggui
 * @LastEditTime: 2024-01-17 16:15:00
 * @Descripttion:
-->
<template>
  <div class="AssetCount-wrap">
    <div>
      <el-tooltip
      placement="bottom"
      :disabled="item.weaknessCount <= 0 ? true : false"
    >
      <template v-slot:content>
        <div v-if="item.weaknessCount" class="content">
          <p v-for="(child, index) in item.weaknessSortByLevel" :key="index">
            <span>{{ child.key }}</span>
            <span>{{ child.docCount }}</span>
          </p>
        </div>
      </template>
      <div>
        <span class="name">存在弱点</span>
        <span class="count">{{ item.weaknessCount }}</span>
      </div>
    </el-tooltip>
    </div>
    <div>
      <el-tooltip
          placement="bottom"
          :disabled="dataSourceNum <= 0 ? true : false"
      >
        <template v-slot:content>
          <div v-if="dataSource" class="content">
            <p v-for="(tag, index) in dataSource.split(',')" :key="index">
              {{ tag }}
            </p>
          </div>
        </template>
        <div>
          <span class="name">暴露源</span>
          <span class="count">{{ dataSourceNum }}</span>
        </div>
      </el-tooltip>
    </div>
  </div>
</template>

<script lang="ts" setup> 
import {defineProps,computed} from 'vue';
const props=defineProps({
  item: {
      type: Object,
      default: () => {
        return {}
      },
    },
})
const dataSource=computed(()=>{
  return props.item.dataSource || props.item.sourceName
})
const dataSourceNum=computed(()=>{
  if (props.item.dataSource) {
        return props.item.dataSource.split(',').length
      }
      return 0
})

</script>
<style lang="scss" scoped>
.AssetCount-wrap {
  display: flex;
  align-items: center;

  > div {
    &:first-child {
      margin-right: 10px;
    }

    .name {
      margin-right: 7px;
      font-family: PingFangSC-Regular;
      font-size: 12px;
      line-height: 20px;
      letter-spacing: 0px;
      // color: rgba(255, 255, 255, 0.8);
    }

    .count {
      font-family: PingFangSC-Medium;
      font-size: 16px;
      line-height: 22px;
      letter-spacing: 0px;
      color: #0289f7;
    }
  }
}
</style>
